<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div class="wraper" style="width:100px;height: 100px;background:green"></div>
<script>
  var wraper = document.getElementsByClassName('wraper')[0];

  function addEven(elm, type, fn) {
    if (elm.addEventListener) {
      elm.addEventListener(type, function () {
        fn.call(elm);
      }, false);
    } else if (elm.attachEvent) {
      console.log('ie');
      elm.attachEvent('on' + type, function () {
        fn.call(elm)
      });
    } else {
      elm['on' + type] = fn;
    }
  }
  addEven(wraper, 'click', function () {
    this.style.backgroundColor = 'red';
  })
</script>
</body>
</html>